package com.tiancheng.trade.payment.controller.admin;

import com.tiancheng.trade.commom.core.data.Result;
import com.tiancheng.trade.payment.service.PaymentOrderService;
import com.tiancheng.trade.payment.vo.admin.PaymentFlowQueryVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 支付流水
 */
@RestController
@RequestMapping("/admin/flow")
@Validated
@Slf4j
public class PaymentFlowAdminController {

	@Autowired
	PaymentOrderService paymentOrderService;

	/**
	 * 根据id获取支付流水
	 *
	 * @param id
	 * @return
	 */
	@GetMapping("/{id}")
	public Result get(@PathVariable Long id) {
		return Result.success(paymentOrderService.getInfo(id));
	}

	/**
	 * 分页查询支付流水
	 *
	 * @param paymentFlowQueryVo
	 * @return
	 */
	@GetMapping("/findPageList")
	public Result findList(PaymentFlowQueryVo paymentFlowQueryVo) {
		return Result.success(paymentOrderService.findList(paymentFlowQueryVo));
	}

	/**
	 * 导出渠道支付订单
	 */
	@PostMapping("/exportList")
	public Result exportList(@RequestBody PaymentFlowQueryVo paymentFlowQueryVo, HttpServletResponse response) throws IOException {
		return paymentOrderService.exportList(paymentFlowQueryVo, response);
	}
}
